package com.bianxingji.service.impl;



import com.bianxingji.mapper.BxjMediaFilesMapper;
import com.bianxingji.po.BxjMediaFiles;
import com.bianxingji.service.BxjMediaFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @description TODO
 * @author Mr.M
 * @date 2022/9/10 8:58
 * @version 1.0
 */
@Slf4j
@Service
public class BxjMediaFileServiceImpl implements BxjMediaFileService {

  @Autowired
  BxjMediaFilesMapper bxjMediaFilesMapper;

 //存储普通文件
 @Value("${minio.bucket.files}")
 private String bucket_img;
 @Value("${minio.bucket.videofiles}")
 private String bucket_video;
 @Value("${minio.endpoint}")
 private String endpoint;

 @Override
 public String getUrlById(boolean isImg,String id) {
  BxjMediaFiles bxjMediaFiles = bxjMediaFilesMapper.selectById(id);
  return  !Objects.isNull(bxjMediaFiles) ? endpoint+"/"+ (isImg ?bucket_img:bucket_video) +"/"+bxjMediaFiles.getUrl():"";
 }
}
